package com.paomi.client.activity.address.presenter;

import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.hannesdorfmann.mosby3.mvp.MvpView;
import com.paomi.client.activity.address.View.ReceivingAddressView;
import com.paomi.client.bean.AddressListInfo;
import com.paomi.client.bean.BaseJSON;
import com.paomi.client.net.Api;
import com.paomi.client.net.BaseCallback;
import com.paomi.client.net.Constants;
import com.paomi.client.utils.Util;

import java.util.Map;

import retrofit2.Call;

public class ReceivingAddressPre extends MvpBasePresenter<ReceivingAddressView> {
    /**
     * 获取地址列表
     */
    public void getAddressNum(Map<String, String> map) {
        Api.getInstanceService(Constants.User_URL).getAddressList(map).enqueue(new BaseCallback<AddressListInfo>() {
            @Override
            public void onResponse(Call<AddressListInfo> call, AddressListInfo result) {
                if(isViewAttached()) {
                    getView().showAddressList(result);
                }
            }
        });
    }

    /**
     * 删除地址
     */
    public void deleteAddress(String id,int pos) {
        Api.getInstanceService(Constants.User_URL).addressDelete(id).enqueue(new BaseCallback<BaseJSON>() {
            @Override
            public void onResponse(Call<BaseJSON> call, BaseJSON result) {
                    getView().deleteSuccess(result,pos);
            }
        });
    }

}
